package com.site_assembly.apiImpl;

import com.rt.info.api.ComplaintApi;
import com.service.ComplaintApiService;
import com.service.form.ComplaintForm;
import com.site_assembly.common.GetIdUtil;
import com.util.Result;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;


@RestController
@Api(tags = "子站点端（投诉信息）接口", description = "提供子站点（投诉信息）相关的 Rest API")
public class ComplaintApiImpl implements ComplaintApiService {

    @Resource
    private ComplaintApi complaintApi;

    @Resource
    private GetIdUtil getIdUtil;

    @Override
    @ApiOperation("根据投诉信息状态查询站点所有投诉信息")
    public Result findAllComplaintBySiteIdAndComplaintStateAndPage(@ApiParam(name = "complaintState", value = "投诉信息状态") String complaintState,
                                                                   @ApiParam(name = "current", value = "当前页", example = "1") Integer current,
                                                                   @ApiParam(name = "pageSize", value = "页容量", example = "1") Integer pageSize) {
       //解析请求头jwt获取站点id
        Integer siteId = getIdUtil.getId();

        Result complaint = complaintApi.findComplaint(pageSize, current, siteId, complaintState);
        return complaint;
    }

    @Override
    @ApiOperation("站点投诉信息处理")
    @ApiResponses({@ApiResponse(code = 20000, message = "修改成功"), @ApiResponse(code = 40000, message = "修改失败")})
    public Result setComplaintByComplaintId(@ApiParam(name = "complaintResponse", value = "站点回复") String complaintResponse,
                                            @ApiParam(name = "complaintId", value = "投诉信息Id", example = "1") Integer complaintId) {

        Result result = complaintApi.handleComplaint(complaintResponse, complaintId);
        return result;
    }
}
